/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @return {TreeNode}
 * @param val
 * @param left
 * @param right
 */


//创建二叉树
function TreeNode(val, left, right) {
  this.val = (val===undefined ? 0 : val)
  this.left = (left===undefined ? null : left)
  this.right = (right===undefined ? null : right)
}
 function createTree(arr){
  let root = new TreeNode(arr[0]);
  let queue = [root];
  let i = 1;
  while(i < arr.length){
    let node = queue.shift();
    if(arr[i] !== null){
      node.left = new TreeNode(arr[i]);
      queue.push(node.left);
    }
    i++;
  }
  console.log(root);
  return root;
}

export{
  createTree,
  TreeNode
}

